﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Neits.ConfigurationService;

namespace Projecturo.Connectivity
{
    public class Connectivity : IConnectivity
    {
        private IAuthentication authentication;
        private IStorage storage;

        [Dependency]
        public IUnityContainer UnityContainer
        {
            get;
            set;
        }

        #region IConnectivity Member

        public IAuthentication Authentication
        {
            get
            {
                if (this.authentication == null)
                {
                    this.authentication = UnityContainer.Resolve<IAuthentication>();
                    this.authentication = UnityContainer.BuildUp<IAuthentication>(this.authentication);
                }
                return this.authentication;
            }
        }

        public IStorage Storage
        {
            get
            {
                if (this.storage == null)
                {
                    this.storage = UnityContainer.Resolve<IStorage>();
                    this.storage = UnityContainer.BuildUp<IStorage>(this.storage);
                }
                return this.storage;
            }
        }

        #endregion
    }
}
